cmake_minimum_required(VERSION 3.10)

find_package(glfw3 REQUIRED)
find_package(glm REQUIRED)
find_package(plog REQUIRED)

# 添加glad源文件
set(GLAD_SRC ${CMAKE_SOURCE_DIR}/src/glad.c)

# 编译着色器源文件
set(SHADER_FILES
    ${CMAKE_CURRENT_SOURCE_DIR}/camera.vs
    ${CMAKE_CURRENT_SOURCE_DIR}/camera.fs
)

# 添加可执行文件
add_executable(camera_circle 1.camera_circle.cpp ${GLAD_SRC})
add_executable(camera_keyboard 2.camera_keyboard.cpp ${GLAD_SRC})
add_executable(camera_mouse 3.camera_mouse.cpp ${GLAD_SRC})
add_executable(camera_class 4.camera_class.cpp ${GLAD_SRC})

set(PLATFORM_LIBS glfw glm::glm plog::plog stb_image)

# 为每个可执行文件设置链接库
foreach(TARGET camera_circle camera_keyboard camera_mouse camera_class)
    target_link_libraries(${TARGET} ${PLATFORM_LIBS})
    
    # 将着色器文件复制到二进制目录
    foreach(SHADER ${SHADER_FILES})
        add_custom_command(
            TARGET ${TARGET} POST_BUILD
            COMMAND ${CMAKE_COMMAND} -E copy
            ${SHADER}
            $<TARGET_FILE_DIR:${TARGET}>
        )
    endforeach()
    
    # 复制纹理资源文件夹
    add_custom_command(
        TARGET ${TARGET} POST_BUILD
        COMMAND ${CMAKE_COMMAND} -E copy_directory
        ${CMAKE_SOURCE_DIR}/resource/texture
        $<TARGET_FILE_DIR:${TARGET}>/resource/texture
    )
endforeach() 